/**
 * <code>gui</code> ist ein Package für alle Fenster
 */
package jermedit.gui;


import java.io.File;

import javax.swing.JScrollPane;
import jermedit.gobjekte.LineObject;
import jermedit.gobjekte.Relationship;
import jermedit.gobjekte.PolygonObject;





public class GuiJFrame extends javax.swing.JFrame {
    /**
     * Custom jPanel for creating jScrollPane
     * we need to be able to use this Instance methods
     * from this class
     */
    public GuiJPanel guiJPanelObj = new GuiJPanel();
     
    /**
     * Creates new form GuiJFrame
     */
    public GuiJFrame() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFileChooser = new javax.swing.JFileChooser();
        ContextMenu = new javax.swing.JPopupMenu();
        Delete = new javax.swing.JMenuItem();
        jScrollPane = new JScrollPane(guiJPanelObj);
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton_Systemtyp = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton_Raute = new javax.swing.JButton();
        jButton_GPfeil = new javax.swing.JButton();
        jButton_Pfeil = new javax.swing.JButton();
        jButton_Linie = new javax.swing.JButton();
        jButtonPointer = new javax.swing.JButton();
        menu = new javax.swing.JMenuBar();
        jMenu_File = new javax.swing.JMenu();
        jMenuItem_New = new javax.swing.JMenuItem();
        jMenuItem_Open = new javax.swing.JMenuItem();
        jMenuItem_Save = new javax.swing.JMenuItem();
        jSeparator_File1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem_Print = new javax.swing.JMenuItem();
        jSeparator_File2 = new javax.swing.JPopupMenu.Separator();
        jMenuItem_Exit = new javax.swing.JMenuItem();
        jMenu_Edit = new javax.swing.JMenu();
        jSeparator_Edit1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem_Delete = new javax.swing.JMenuItem();
        jSeparator_Edit2 = new javax.swing.JPopupMenu.Separator();
        jMenuItem_Rename = new javax.swing.JMenuItem();
        jMenu_Help = new javax.swing.JMenu();
        jMenuItem_Manual = new javax.swing.JMenuItem();
        jMenuItem_Info = new javax.swing.JMenuItem();

        jFileChooser.setDialogTitle("Choose File");
        jFileChooser.setFileFilter(new MyCustomFilter());

        Delete.setText("Delete");
        ContextMenu.add(Delete);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/Rechteck3.gif"))); // NOI18N
        jButton1.setText("Objekttyp");
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/Kreis2.png"))); // NOI18N
        jButton2.setText("Kreis");
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/Basis-System.gif"))); // NOI18N
        jButton3.setText("Basistyp");
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton_Systemtyp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/Basis-System.gif"))); // NOI18N
        jButton_Systemtyp.setText("Systemtyp");
        jButton_Systemtyp.setToolTipText("Systemtyp");
        jButton_Systemtyp.setFocusable(false);
        jButton_Systemtyp.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_Systemtyp.setName(""); // NOI18N
        jButton_Systemtyp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton_Systemtyp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_SystemtypActionPerformed(evt);
            }
        });

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/RaRe4.png"))); // NOI18N
        jButton4.setText("ObjAssTyp");
        jButton4.setFocusable(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setMaximumSize(new java.awt.Dimension(80, 40));
        jButton4.setMinimumSize(new java.awt.Dimension(80, 40));
        jButton4.setPreferredSize(new java.awt.Dimension(80, 40));
        jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/EEnum.gif"))); // NOI18N
        jButton5.setText("Enumtyp");
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton_Raute.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/raa.png"))); // NOI18N
        jButton_Raute.setText("Raute");
        jButton_Raute.setFocusable(false);
        jButton_Raute.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_Raute.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton_Raute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_RauteActionPerformed(evt);
            }
        });

        jButton_GPfeil.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/GPfeil.png"))); // NOI18N
        jButton_GPfeil.setText("Repres.-by");
        jButton_GPfeil.setFocusable(false);
        jButton_GPfeil.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_GPfeil.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton_GPfeil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_GPfeilActionPerformed(evt);
            }
        });

        jButton_Pfeil.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/Pfeil.png"))); // NOI18N
        jButton_Pfeil.setText("Vererbung");
        jButton_Pfeil.setFocusable(false);
        jButton_Pfeil.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_Pfeil.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton_Pfeil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_PfeilActionPerformed(evt);
            }
        });

        jButton_Linie.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jermedit/gui/imgs/Rollemit.png"))); // NOI18N
        jButton_Linie.setText("Rolle");
        jButton_Linie.setFocusable(false);
        jButton_Linie.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_Linie.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton_Linie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_LinieActionPerformed(evt);
            }
        });

        jButtonPointer.setText("Select");
        jButtonPointer.setFocusable(false);
        jButtonPointer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonPointer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonPointer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPointerActionPerformed(evt);
            }
        });

        jMenu_File.setText("File");

        jMenuItem_New.setText("New");
        jMenuItem_New.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_NewActionPerformed(evt);
            }
        });
        jMenu_File.add(jMenuItem_New);

        jMenuItem_Open.setText("Open");
        jMenuItem_Open.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_OpenActionPerformed(evt);
            }
        });
        jMenu_File.add(jMenuItem_Open);

        jMenuItem_Save.setText("Save");
        jMenuItem_Save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_SaveActionPerformed(evt);
            }
        });
        jMenu_File.add(jMenuItem_Save);
        jMenu_File.add(jSeparator_File1);

        jMenuItem_Print.setText("Print");
        jMenuItem_Print.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_PrintActionPerformed(evt);
            }
        });
        jMenu_File.add(jMenuItem_Print);
        jMenu_File.add(jSeparator_File2);

        jMenuItem_Exit.setText("Exit");
        jMenuItem_Exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_ExitActionPerformed(evt);
            }
        });
        jMenu_File.add(jMenuItem_Exit);

        menu.add(jMenu_File);

        jMenu_Edit.setText("Edit");
        jMenu_Edit.add(jSeparator_Edit1);

        jMenuItem_Delete.setText("Delete");
        jMenuItem_Delete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_DeleteActionPerformed(evt);
            }
        });
        jMenu_Edit.add(jMenuItem_Delete);
        jMenu_Edit.add(jSeparator_Edit2);

        jMenuItem_Rename.setText("Rename");
        jMenuItem_Rename.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_RenameActionPerformed(evt);
            }
        });
        jMenu_Edit.add(jMenuItem_Rename);

        menu.add(jMenu_Edit);

        jMenu_Help.setText("Help");

        jMenuItem_Manual.setText("Manual");
        jMenu_Help.add(jMenuItem_Manual);

        jMenuItem_Info.setText("Info");
        jMenu_Help.add(jMenuItem_Info);

        menu.add(jMenu_Help);

        setJMenuBar(menu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_Systemtyp, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton_Raute, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_GPfeil, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton_Linie, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_Pfeil, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButtonPointer, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 686, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_Systemtyp, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_Raute, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_GPfeil, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton_Pfeil, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_Linie, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonPointer, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(92, Short.MAX_VALUE))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem_NewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_NewActionPerformed
        guiJPanelObj.resetWindow();
        jScrollPane.setViewportView(guiJPanelObj);
    }//GEN-LAST:event_jMenuItem_NewActionPerformed

    private void jMenuItem_ExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_ExitActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenuItem_ExitActionPerformed

    private void jMenuItem_OpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_OpenActionPerformed
        // Open File
        int returnVal = jFileChooser.showOpenDialog(this);
        if (returnVal == jFileChooser.APPROVE_OPTION) {
            File file = jFileChooser.getSelectedFile();
            guiJPanelObj.openFile(file);
            this.repaint();          
        } else {
            System.out.println("File access cancelled by user.");
        }
    }//GEN-LAST:event_jMenuItem_OpenActionPerformed

    private void jButtonPointerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPointerActionPerformed
        guiJPanelObj.setMouseState(MouseState.SELECTOR);
    }//GEN-LAST:event_jButtonPointerActionPerformed

    private void jButton_PfeilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_PfeilActionPerformed
        // Add Hardcoded Pfeil
        guiJPanelObj.setMouseState(MouseState.ADDINGLINE, MouseState.GENERALIZATION);
    }//GEN-LAST:event_jButton_PfeilActionPerformed

    private void jButton_GPfeilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_GPfeilActionPerformed
        // TODO add your handling code here:
        guiJPanelObj.setMouseState(MouseState.ADDINGLINE, MouseState.REPRESENTEDBY);
    }//GEN-LAST:event_jButton_GPfeilActionPerformed

    private void jButton_LinieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_LinieActionPerformed
        // TODO add your handling code here:
        guiJPanelObj.setMouseState(MouseState.ADDINGLINE, MouseState.ASSOTIATION);
        
    }//GEN-LAST:event_jButton_LinieActionPerformed

    private void jMenuItem_SaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_SaveActionPerformed
        // Speicherfunktion, jetzt mit zwei Listen
        int returnVal = jFileChooser.showSaveDialog(this);
        if (returnVal == jFileChooser.APPROVE_OPTION) {
            File file = jFileChooser.getSelectedFile();
            
            guiJPanelObj.saveFile(file);
        } else {
            System.out.println("File access cancelled by user.");
        }
    }//GEN-LAST:event_jMenuItem_SaveActionPerformed

    private void jButton_RauteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_RauteActionPerformed
        // add your handling code here:
        guiJPanelObj.setMouseState(MouseState.ASSOSIATIONTYPE);
    }//GEN-LAST:event_jButton_RauteActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // add Rechteck:
        guiJPanelObj.setMouseState(MouseState.OBJECTTYPE);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // add Kreis:
        guiJPanelObj.setMouseState(MouseState.XOR);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        guiJPanelObj.setMouseState(MouseState.OBJASSTYPE);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        guiJPanelObj.setMouseState(MouseState.EUNMTYPE);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton_SystemtypActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_SystemtypActionPerformed
        guiJPanelObj.setMouseState(MouseState.SYSTEMTYPE);
    }//GEN-LAST:event_jButton_SystemtypActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // add Basistyp:
        guiJPanelObj.setMouseState(MouseState.BASETYPE);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jMenuItem_DeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_DeleteActionPerformed
        guiJPanelObj.deleteSelected();       
    }//GEN-LAST:event_jMenuItem_DeleteActionPerformed

    private void jMenuItem_PrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_PrintActionPerformed
        new PrinterDriver(GuiJPanel.window);
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem_PrintActionPerformed

    private void jMenuItem_RenameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_RenameActionPerformed
        // TODO add your handling code here:
//        guiJPanelObj
        for (LineObject ger : guiJPanelObj.listOfGeraden){
                        
                    if(ger.isSelected()==true){
                        if(ger instanceof Relationship) guiJPanelObj.rename(ger,1);
                    break;
                    }
                }
                for (PolygonObject zo : guiJPanelObj.listOfZeichenobjekte){
                    if(zo.isSelected()==true){
                        zo.umbenennen();
                        repaint();
                        break;
                    }
                }
    }//GEN-LAST:event_jMenuItem_RenameActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GuiJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GuiJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GuiJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GuiJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GuiJFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPopupMenu ContextMenu;
    private javax.swing.JMenuItem Delete;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButtonPointer;
    private javax.swing.JButton jButton_GPfeil;
    private javax.swing.JButton jButton_Linie;
    private javax.swing.JButton jButton_Pfeil;
    private javax.swing.JButton jButton_Raute;
    private javax.swing.JButton jButton_Systemtyp;
    private javax.swing.JFileChooser jFileChooser;
    private javax.swing.JMenuItem jMenuItem_Delete;
    private javax.swing.JMenuItem jMenuItem_Exit;
    private javax.swing.JMenuItem jMenuItem_Info;
    private javax.swing.JMenuItem jMenuItem_Manual;
    private javax.swing.JMenuItem jMenuItem_New;
    private javax.swing.JMenuItem jMenuItem_Open;
    private javax.swing.JMenuItem jMenuItem_Print;
    private javax.swing.JMenuItem jMenuItem_Rename;
    private javax.swing.JMenuItem jMenuItem_Save;
    private javax.swing.JMenu jMenu_Edit;
    private javax.swing.JMenu jMenu_File;
    private javax.swing.JMenu jMenu_Help;
    private javax.swing.JScrollPane jScrollPane;
    private javax.swing.JPopupMenu.Separator jSeparator_Edit1;
    private javax.swing.JPopupMenu.Separator jSeparator_Edit2;
    private javax.swing.JPopupMenu.Separator jSeparator_File1;
    private javax.swing.JPopupMenu.Separator jSeparator_File2;
    private javax.swing.JMenuBar menu;
    // End of variables declaration//GEN-END:variables

    /**
     * Test Method to show the jPanel Size inside the jFrame
     */
    private void showActualjPanelSize() {
                System.out.println(
                        "Jpanel      Hight:" + guiJPanelObj.getHeight() +
                        " Width:" + guiJPanelObj.getWidth() + "\n" +
                        "JScrollPane Hight:" + jScrollPane.getHeight() +
                        " Width:" + jScrollPane.getWidth()
                        );
    }
    
     /**
      * Custom FileFilter for our Saving Extention
      * Right now it uses .txt files
      */
     class MyCustomFilter extends javax.swing.filechooser.FileFilter {
        @Override
        public boolean accept(File file) {
            // Allow only directories, or files with ".txt" extension
            return file.isDirectory() || file.getAbsolutePath().endsWith(".txt");
        }
        @Override
        public String getDescription() {
            // This description will be displayed in the dialog,
            // hard-coded = ugly, should be done via I18N
            return "Text documents (*.txt)";
        }
     }
     
     

     
     
}

